package com.cswnode.demo.controller;

import com.cswnode.demo.entity.Resume;
import com.cswnode.demo.service.ResumeService;
import com.cswnode.demo.util.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 简历(Resume)表控制层
 *
 * @author makejava
 * @since 2021-03-26 16:05:35
 */
@Api(tags = "在线简历模块")
@RestController
@RequestMapping("/resume")
public class ResumeController {
    /**
     * 服务对象
     */
    @Resource
    private ResumeService resumeService;

    @ApiOperation(value = "获得当前用户得简历")
    @GetMapping("/get")
    public ResponseVo getResume(){
        Resume resume = resumeService.queryById();
        return ResponseVo.success(resume);
    }

    @ApiOperation(value = "修改简历")
    @PostMapping("/update")
    public ResponseVo update(@RequestBody Resume resume){
        resumeService.update(resume);
        return ResponseVo.success("修改成功！");
    }

    @ApiOperation(value = "发送简历")
    @GetMapping("/send/{postId}")
    public ResponseVo send(@PathVariable("postId") Long postId){
        String s = resumeService.sendResume(postId);
        if (null == s){
            return ResponseVo.success("简历发送成功！");
        }
        return ResponseVo.error(s);

    }

    @ApiOperation(value = "获得岗位简历")
    @GetMapping("/getPostResume/{postId}")
    public ResponseVo getPostResume(@PathVariable("postId") Long postId){
        if (postId == null){
            return ResponseVo.success(null);
        }
        List<Resume> resume = resumeService.getResume(postId);
        return ResponseVo.success(resume);
    }



}